/**
 * 
 */
package com.security.core.validate.code.sms;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.context.request.ServletWebRequest;

import com.security.core.validate.code.ValidateCode;
import com.security.core.validate.code.impl.AbstractValidateCodeProcessor;

/**
 * @title SmsCodeProcessor
 * @version 1.0.0
 * @description 短信验证码生成
 * @author Dark_blue
 * @date 2019年8月12日
 */
@Component("smsCodeProcessor")
public class SmsCodeProcessor extends AbstractValidateCodeProcessor<ValidateCode>{
	
	@Autowired
	private SmsCodeSender smsCodeSender;

	@Override
	protected void send(ServletWebRequest request, ValidateCode validateCode) throws Exception {
		String mobile = ServletRequestUtils.getRequiredStringParameter(request.getRequest(), "mobile");
		smsCodeSender.send(mobile, validateCode.getCode());
	}

}
